package com.ffcs.crmd.tsp.core.netty.client;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;

/**
 * 
 * 功能说明:netty通道的包装类
 *
 * @author ZHONGFUHUA
 * 
 * @since 1.0.0-SNAPSHOT
 *
 */
public class NettyChannelWrapper {
    
    /**
     * 通道结果
     */
    private final ChannelFuture channelFuture;


    public NettyChannelWrapper(ChannelFuture channelFuture) {
        this.channelFuture = channelFuture;
    }

    /**
     * 
     * 功能说明: 通道状态是否OK
     * 
     * @return ok与否
     */
    public boolean isOK() {
        return (this.channelFuture.channel() != null && this.channelFuture.channel().isActive());
    }


    /**
     * 
     * 功能说明:通道是否可写内容
     * 
     * @return 是否可写
     */
    public boolean isWriteable() {
        return this.channelFuture.channel().isWritable();
    }


    /**
     * 
     * 功能说明:获取通道
     * 
     * @return 通道
     */
    public Channel getChannel() {
        return this.channelFuture.channel();
    }

    /**
     * 
     * 功能说明:获取通道结果
     * 
     * @return 通道结果
     */
    public ChannelFuture getChannelFuture() {
        return channelFuture;
    }
}
